﻿//用于数据验证
function _$(id) {
    return document.getElementById(id);
}
var valObj = {
    //验证该值是否为空
    RequiredFieldIsNullOrEmpty: function(value) {
        var Has = false;
        if (value == null || value == "" || value == undefined) {
            Has = true;
        }
        return Has;
    },

    /*
    用于验证控件指定的属性值是否为空
    control指定的控件
    propertyName指定的控件的属性名
    */
    RequiredControlValue: function(control, propertyName) {
        if (control == undefined || control == null) {
            alert('对象不存在');
            return true;
        }
        try {
            var value = control[propertyName];
            if (value == undefined) {
                alert('该对象不包含该属性:' + propertyName);
                return true;
            }
            return valObj.RequiredFieldIsNullOrEmpty(value);
        }
        catch (e) {
        }
    },
    /*
    用于验证控件指定的属性值是否为空
    controlId指定的控件的Id
    propertyName指定的控件的属性名
    */
    RequiredControlValueByControlId: function(controlId, propertyName) {
    var control = _$(controlId);
        return valObj.RequiredControlValue(control, propertyName);
    }
};